package manager.server.factory{
	import flash.utils.ByteArray;
	
	/**
	 * 指令集基类
	 * byteArray
	 * type
	 * isocketcommand
	 * 向byte写入type类型
	 */	
	public class SocketCommandBase {
		private var _byteArray:ByteArray;  		  //临时存储socket数据
		private var _type:int;			  		  //指令集类型
		private var _socketCommand:ISocketCommand;//指令集工厂

		public function SocketCommandBase(){
			_byteArray = new ByteArray();
		}
		
		/**写入数据type 占两个字节**/
		public function write():void {
			_byteArray.writeShort(_type);
		}

		/**
		 * 对接收的Socket信息进行解码
		 * 基类先读取type的值 
		 * 返回对象
		 */
		public function decodeSocketData(byteArray:ByteArray):ISocketCommand {
			_type = byteArray.readShort();
			return _socketCommand;
		}
		
		/**设置byte值*/
		public function set byteArray(value:ByteArray):void {
			_byteArray = value;
		}

		public function get byteArray():ByteArray {
			return _byteArray;
		}
		
		/**设置type值*/
		public function get type():int {
			return _type;
		}

		public function set type(value:int):void {
			_type = value;
		}
		
		/**设置接口值*/
		public function get socketCommand():ISocketCommand {
			return _socketCommand;
		}

		public function set socketCommand(value:ISocketCommand):void {
			_socketCommand = value;
		}
	}
}